using System;
using System.Collections;

namespace MULENetworking
{
    public delegate void TransferMessageCallBack( string msg );
    public delegate void ConnectingUserCallBack(string userName);
    public delegate void DisconnectingUserCallBack(string userName);
    public delegate void KickUserCallBack(string userName);
    public delegate void CreateGameCallBack(string gameName);

    public interface IEventChat
    {
        string chatText { get; set; }
        ArrayList chatUserList { get; set; }
        string updateChatText(string incomingText);
        
        event TransferMessageCallBack TransferMessage;
        event ConnectingUserCallBack ConnectingUser;
        event DisconnectingUserCallBack DisconnectingUser;
        event KickUserCallBack KickUser;
        event CreateGameCallBack CreateGame;
    }

    public class EventShim : MarshalByRefObject
    {
        private TransferMessageCallBack xferMsg;
        private ConnectingUserCallBack connUser;
        private DisconnectingUserCallBack dissconnUser;
        private KickUserCallBack kickUser;
        private CreateGameCallBack creGame;

        private EventShim(TransferMessageCallBack target)
        {
            this.xferMsg += target;
        }

        private EventShim(ConnectingUserCallBack target)
        {
            this.connUser += target;
        }

        private EventShim(DisconnectingUserCallBack target)
        {
            this.dissconnUser += target;
        }

        private EventShim(KickUserCallBack target)
        {
            this.kickUser += target;
        }

        private EventShim(CreateGameCallBack target)
        {
            this.creGame += target;
        }

        //TODO
        public void MagicNumberShim(int n, string blahdy)
        {
            target(n, blahdy);
        }

        public static MagicNumberCallback Create(MagicNumberCallback target)
        {
            EventShim shim = new EventShim(target);
            return new MagicNumberCallback(shim.MagicNumberShim);
        }
    }

    public class ChatRoomEvents
    {
        public string type = "";
        public enum type { transferMsg = 0, connectUser = 1, disconnectUser = 2, kickUser = 3, createGame = 4 }
        public TransferMessageCallBack transferMsg;
        public ConnectingUserCallBack connectUser;
        public DisconnectingUserCallBack disconnectUser;
        public KickUserCallBack kickUser;
        public CreateGameCallBack createGame;
    }
}
